<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>所有申请书查询</title>
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>
</head>

<body>
	<input type="hidden" id="childDiv" class="thickbox" />
	<form method="post" id="mainForm">
			<input type="hidden" id="prpCodes" name="prpCodes" value="" />
			<input type="hidden" id="type" name="type" value="" />
		</form>

	<div class="soBox">
		<div class="detail ico_search">
			<table>
				<tr>
					<td rowspan="2"><strong>检索条件：</strong>
					</td>
						
					<td>
						<cpt:search key="prpApprove_search_chushi_all"  repeatColumn="3" displayCount="6" leftStyle="width:100px"></cpt:search>
					</td>
					
					
				</tr>
				<tr>
				<td>
					<div class="clear_h10"></div>
					<input type='button' id='searchBt' class="button_an" value='查询' />
				</td>
				</tr>
			</table>
		</div>
	</div>
	<div class="clear_h10"></div>
	<div>
		<div id='TopBarMnt'></div>
		<table id='dataGrid'></table>
		<div id='dataBar'></div>
	</div>

	<script type="text/javascript">
	var irisGrid = new IrisGrid("dataGrid", "dataBar", 'TopBarMnt');
	var prcWin = new progressWin("${res}");//初始化遮罩层
	function showApproveDialog(type){
		var prpCodes="";
		
		$(":checkbox:checked").each(function(){
			var rowId=$(this).attr("id");
			var id=rowId.substring(rowId.lastIndexOf("_")+1,rowId.length);//取出grid中需要的id
			if(id!=null&&id!=""&&$.isNumeric(id))
				prpCodes=prpCodes+id+",";
		});
		
		if(prpCodes==""){
			scmError("请选择一条记录");
			return false;
		}
		if(type=="approve"){
				
				var prpnum = prpCodes.split(",").length-1;
				$("#prpCodes").val(prpCodes);
				$("#type").val(type);
				var options = {
						beforeSubmit : function() {
							prcWin.openWin();//打开遮罩层
							$("#approve").attr("disabled",true);
						}, // 表单提交前的回调函数
						success : function(msg) {
							prcWin.closeWin();
							scmSuccess(msg);
							irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
							$("#approve").attr("disabled",false);
						},// 表单成功提交后的回调函数
						error : function() {
							scmError("操作失败,请联系系统管理员");
							prcWin.closeWin();
							$("#approve").attr("disabled",false);
						},
						url: "${ctx}/prpapprove/"+type
					};
				if(confirm("是否确认此"+prpnum+"份申请书?")){
					$("#mainForm").ajaxSubmit(options);
				}
				else{
					return;
				}
			
		}else{
			var url="${ctx}/prpapprove/openprpapprovedialog?prpCodes="+prpCodes+"&type="+type+"&TB_iframe=true&height=220&width=400";
			var title="申报审核意见（最多为500字）";
			showThickBox(url,title);
		}
		
	}
	
	function checkSelect(){
		var selectArray=irisGrid.getGridDom().jqGrid("getGridParam", 'selarrrow');//获得选中行
		$("#approve").removeAttr("disabled");//去除该属性
		for(var i=0;i<selectArray.length;i++){
			var status=irisGrid.getGridDom().jqGrid('getCell',selectArray[i],"13");
			var flagCan=irisGrid.getGridDom().jqGrid('getCell',selectArray[i],"14");
			if(status=='01'&&flagCan=="0") {
				$("#approve").attr("disabled","disabled");
				scmError("您所选择的这"+selectArray.length+"份申请书中有部分申请书的正式PDF未生成，请在生成之后再选择该申请书进行确认操作");
			}
		}
	}
	
	function viewComment(des3Prpcode){
		var url="${ctx}/proposal/view/audit-comment-view?posCode="+des3Prpcode+"&TB_iframe=true&height=390&width=720";
		var title="审核意见";
		showThickBox(url,title);	
	}
	
	function closeDialog(){
		tb_remove();
	}

	
		/** 表格初始化**/
		//loadIrisGrid("${res}");
		function buildGrid() {
			var columnAttrList = new Array();
			columnAttr = new ColumnAttr("项目类别", "grant_name","grant_name", 4, "left", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("项目名称", "zh_title","zh_title", 4, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			
			
			columnAttr = new ColumnAttr("受理编号", "prp_no","prp_no", 4, "left", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("申报单位", "org_name","org_name", 3, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("单位法人", "psn_name","psn_name", 3, "center", true);
			columnAttrList.push(columnAttr);
			
			
			columnAttr = new ColumnAttr("主管单位", "off_name", "off_name", 3,"center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("认定部门", "tjbm_org_name", "tjbm_org_name", 3,"center", true);
			columnAttrList.push(columnAttr); 
			
			columnAttr = new ColumnAttr("认定类型", "org_hold_type", "org_hold_type", 3,"center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("水印号", "prp_version","prp_version", 3, "left", true);
			columnAttrList.push(columnAttr);
			
			
			columnAttr = new ColumnAttr("证书编号", "print_no","print_no", 3, "left", true);
			columnAttrList.push(columnAttr);
			
			
			columnAttr = new ColumnAttr("审核意见", "comment", "comment", 3,"center", false);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("PDF", "pdf", "pdf",2,"center", false);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("批复结果", "statusName", "status", 2,"center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("status", "status", "status", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("flagCan", "flagCan", "flagCan", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("grantCode", "grantCode", "grantCode", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			irisGrid.setColumnAttrs(columnAttrList);
			irisGrid.setUrl("${ctx}/prpapprove/list-for-cs-view");//查询url
			irisGrid.setCaption("暂写");
			irisGrid.setDefaultSortName("status,NLSSORT(zj_name,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(grant_name,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(area_name,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(org_name,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(psn_name,'NLS_SORT = SCHINESE_PINYIN_M') asc,NLSSORT(zh_title,'NLS_SORT = SCHINESE_PINYIN_M'),prp_no");//默认排序字段
			irisGrid.setDefaultSortorder("asc");
			irisGrid.setWidth(978);//整个表格宽度
			irisGrid.setCheckAble(false);//表格左边是否要复选框
			irisGrid.setShowRowIndex(true);//是否显示行号
			irisGrid.setQueryBox('searchBt', 'prpApprove_search_chushi_all');//查询条件 按钮名，查询条件function_key
			irisGrid.onSelectAll = function(selectid,isSelect){//全选事件
				checkSelect();
			}
			irisGrid.onSelectRow = function(selectid,isSelect){//选择事件	
				checkSelect();
			}
			irisGrid.build();
		}
		jQuery(function() {
			setStatus();
			buildGrid();
		});
		
		
		function setStatus(){
			if('${param.prpstatus}' != ''){
				$("#prpstatus option[value='${param.prpstatus}']").attr("selected","selected");
				//$("#prpstatus option[value='1']").attr("selected", "selected"); 
			}
		}
		
		function printCertificate(prpCode){
			tb_show("打印证书","${ctx}/prpapprove/report-print-certificate?prpCode=" + prpCode
					+ "&TB_iframe=true&height=760&width=1050", false);	
		}
		
		
		/**查看单位信息*/
		function orgInfoView(orgCode){
			//$("#orgCode").val(orgCode);
			//$("#mainForm").submit();
			tb_show("查看单位信息","${ctx}/orgmanage/verifyorg/org-info-view?orgCode=" + orgCode
					+ "&TB_iframe=true&height=460&width=950", false);
		}
		
		function showReportDialog(){
			var searchString=jQuery('#dataGrid').jqGrid('getGridParam','postData')['searchString'];
			if($("#grant_code").val() == '' || $("#grant_code").val()  == undefined)
			{
			 alert("项目类别不能为空");	
			
			}else{
				//先封装数据
				var urlStr = "";
				var criteria_key = $("#_dyn_panel").attr("functionkey");
				var queryTableObj = $("#" + criteria_key + " *[id='_dyn_panel']");
				var querySels = [];
				$("[id^='_dyn_criteria'][id$='_field']", queryTableObj).each(
						function() {
							querySels.push($(this).attr('id'));
						});
				var querySelIdCrowd = querySels;
				
				var queryKVStr = '';
				for ( var i = 0; i < querySelIdCrowd.length; i++) {
					var selId = querySelIdCrowd[i];
					var queryId = $("#"+criteria_key).find('#' + selId).val();
					var destContral = $("#"+criteria_key).find('#' + queryId, $('#' + selId).parent().next());
					var queryValue = destContral.val();
					var fieldname = destContral.attr("name");
					var queryCellValue = $.trim(queryValue);
					if(i != querySelIdCrowd.length-1){
						urlStr = urlStr +fieldname+":"+queryCellValue+"[tear]";
					}else{
						urlStr = urlStr +fieldname+":"+queryCellValue;
					}
				}
			 
			  var statYear=$("#create_year").find("option:selected").text();
				
				tb_show("导出民营科技企业汇总表","${ctx}/prpapprove/list-for-report1"+"?searchString="+encodeURIComponent(urlStr)+"&statYear="+statYear+"&TB_iframe=true&height=460&width=1024", false);
				
			
		}
		}
	</script>
</body>
</html>